#ifndef __ARC20_H_
#define __ARC20_H_

//-----------------------------------------------------------------------------
#include <inttypes.h>

typedef struct arc20_s {
	
	uint8_t  nodeid;
	uint16_t port;
	uint16_t swport;

	uint8_t  use_intr;
	uint8_t  lvl_intr;
	
	uint8_t  stat;
	uint8_t  page;
	uint8_t  offset;
	uint8_t  nbytes;
	uint8_t  diag;
	uint8_t  in_page;
	uint8_t  out_page;
	uint8_t  rx_flag;
	uint8_t  write_ack;
	uint8_t  write_abort;

	uint16_t interrupt_reg;
	uint16_t status_reg;
	uint16_t command_reg;
	uint16_t diag_reg;
	uint16_t addr_hi_reg;
	uint16_t addr_low_reg;
	uint16_t packet_mem;
	uint16_t config_reg;
	uint16_t tentid_reg;
	uint16_t nextid_reg;
	uint16_t nodeid_reg;
	uint16_t setup_reg;
	
} arc20_t;
//-----------------------------------------------------------------------------
#include <sys/iofunc.h>

typedef struct arc20_attr {
	iofunc_attr_t	attr;
	arc20_t			arc20;
} arc20_attr_t;
//-----------------------------------------------------------------------------


int arc20_init (arc20_t *arc20, int base_addr, int lvl_intr);
int arc20_read (arc20_t *arc20, uint8_t *data_ptr);
int arc20_write (arc20_t *arc20, uint8_t *data_ptr);
uint8_t arc20_status (arc20_t *arc20);
void arc20_exit (arc20_t *arc20);
void arc20_write_data (arc20_t *arc20, uint8_t page, uint8_t offset, uint8_t count, uint8_t shortlong, uint8_t *user_buffer);
void arc20_get_check_status (arc20_t *arc20);
void arc20_translate_status (arc20_t *arc20, char *str);
//void interrupt far arc20_interrupt (void);

void net_map (arc20_t *arc20, uint8_t *data_ptr);
void net_tokens (arc20_t *arc20, uint8_t ntokens);

#endif // __ARC20_H_